#include <stdio.h>

int w[10000] = {0};
int t[100] = {0};

int main()
{
	int n = 0, m = 0;
	scanf("%d %d", &n, &m);
	
	for ( int i = 0; i < n; i++ ) {
		scanf("%d", &w[i]);
	}
	
	for ( int i = 0; i < n; i++ ) {
		int minIdx = 0;
		for ( int j = 1; j < m; j++ ) {
			if ( t[minIdx] > t[j] ) {
				minIdx = j;
			}
		}
		t[minIdx] += w[i];
	}
	
	int max = t[0];
	for ( int i = 1; i < m; i++ ) {
		if ( max < t[i] ) {
			max = t[i];
		}
	}
	printf("%d", max);
	return 0;
}
